const { ipcMain } = require('electron');

// 获取当年的工作日和休息日
const getHoliday = ()=> {
    ipcMain.handle('on-server-holiday', (event) => {
        const year = new Date().getFullYear();
        return new Promise((resolve, reject) => {
            fetch('https://api.comm.miui.com/holiday/holiday.jsp')
                .then((res) => {
                    console.log(res)
                    return res.json()
                })
                .then((data) => {
                    const teams = data.holiday.find(item => item.year === year);
                    resolve(teams);
            })
            .catch((error) => {
                reject(error);
            });
        });
    })
}

module.exports = getHoliday;